package com.haierp.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.haierp.mapper.FileManageMapper;
import com.haierp.model.FileManage;
import com.haierp.service.IFileManageService;
import com.haierp.util.JsonPageResult;
import com.haierp.vo.FileManageQueryVO;

@Service("fileManageService")
public class FileManageServiceImpl extends SuperServiceImpl<FileManageMapper, FileManage> implements IFileManageService {
	@Override
	public JsonPageResult<List<FileManage>> queryFiles(FileManageQueryVO fileManageQueryVO) {
		JsonPageResult<List<FileManage>> result = new JsonPageResult<>();
		//1、查询总的记录数量
		Integer totalCount =  this.baseMapper.queryFileCount(fileManageQueryVO);

		//2、查询分页记录
		if(totalCount!=null&&totalCount!=0){
			result.buildPage(totalCount, fileManageQueryVO);
			List<FileManage> fileManages = this.baseMapper.queryFiles(fileManageQueryVO);
			result.setData(fileManages);
		}else{
			List<FileManage> fileManages  = new ArrayList<>();
			result.setData(fileManages);
		}
		return result;
	}
	
	@Override
	public JsonPageResult<List<FileManage>> queryStorageFiles(FileManageQueryVO fileManageQueryVO) {
		JsonPageResult<List<FileManage>> result = new JsonPageResult<>();
		//1、查询总的记录数量
		Integer totalCount =  this.baseMapper.queryStorageFileCount(fileManageQueryVO);

		//2、查询分页记录
		if(totalCount!=null&&totalCount!=0){
			result.buildPage(totalCount, fileManageQueryVO);
			List<FileManage> fileManages = this.baseMapper.queryStorageFiles(fileManageQueryVO);
			result.setData(fileManages);
		}else{
			List<FileManage> fileManages  = new ArrayList<>();
			result.setData(fileManages);
		}
		return result;
	}

	@Override
	public JsonPageResult<List<FileManage>> queryPackerFiles(FileManageQueryVO fileManageQueryVO) {
		JsonPageResult<List<FileManage>> result = new JsonPageResult<>();
		//1、查询总的记录数量
		Integer totalCount =  this.baseMapper.queryPackerFileCount(fileManageQueryVO);

		//2、查询分页记录
		if(totalCount!=null&&totalCount!=0){
			result.buildPage(totalCount, fileManageQueryVO);
			List<FileManage> fileManages = this.baseMapper.queryPackerFiles(fileManageQueryVO);
			result.setData(fileManages);
		}else{
			List<FileManage> fileManages  = new ArrayList<>();
			result.setData(fileManages);
		}
		return result;
	}
}
